#ifndef PREAMBLECTP_H_
#define PREAMBLECTP_H_

#define ROOT_ID 0
#define SPECIAL_ID 0x888
#define AM_DATA_MSG 0x22
#define AM_SNIFFER_MSG 0x23

typedef nx_struct hotmacMsg {
  nx_uint16_t id;
  nx_uint16_t seqno;
  nx_uint16_t parentId;
  nx_uint16_t etx;
  nx_uint16_t len;
  nx_uint16_t misshear;
  nx_uint16_t overhear;
  nx_uint16_t received;
  nx_uint16_t contention;
  nx_uint16_t unicastcont;
  nx_uint16_t forwardcont;
  nx_uint16_t packetsnd;
  nx_uint16_t unicastsnd;
  nx_uint32_t livetime;
  nx_uint32_t dutytime;
} hotmac_msg_t;

typedef nx_struct hotmacLink {
  nx_uint16_t id;
  nx_uint16_t etx;
} hotmac_lnk_t;

typedef nx_struct snifferMsg {
  nx_uint16_t id;
  nx_uint16_t seqno;
  nx_uint16_t parentId;
  nx_uint16_t etx;
  nx_uint32_t interval;
  nx_uint8_t size;
  hotmac_lnk_t lnk[0];
} sniffer_msg_t;

inline uint8_t getPacketLength(sniffer_msg_t* msg) {
  return (sizeof(sniffer_msg_t) + msg->size * sizeof(hotmac_lnk_t));
}

#endif
